package pl.qsoft.db.storedProc.intercept;

import java.util.HashMap;
import java.util.Map;

import pl.qsoft.db.annotation.StoredProcedure;
import pl.qsoft.db.annotation.StoredProcedureDefinition;

/**
 * Context for holding information specific for the given stored procedure invocation. It contains not only stored procedure and stored procedure definition data but also the values that are being passed to the database.
 * Additionally it allows to contain user-specific data in a special contextParams map.  
 * @author Wojciech Kudla
 */
public class ProcedureInvocationContext {

	private StoredProcedureDefinition procedureDefinition;
	private StoredProcedure storedProcedure;
	private Map invocationValues;
	private Map contextParams;
	
		
	public ProcedureInvocationContext(	StoredProcedureDefinition procedureDefinition, StoredProcedure storedProcedure, Map invocationValues) {
		this.procedureDefinition = procedureDefinition;
		this.storedProcedure = storedProcedure;
		this.invocationValues = invocationValues;
		this.contextParams = new HashMap();
	}

	public Map<Object, Object> getContextParams() {
		return contextParams;
	}
	
	public Object getContextParam(Object key) {
		return contextParams.get(key);
	}
	
	public void setContextParam(Object key, Object value) {
		contextParams.put(key, value);
	}

	public Map getInvocationValues() {
		return invocationValues;
	}

	public void setInvocationValues(Map invocationValues) {
		this.invocationValues = invocationValues;
	}

	public StoredProcedureDefinition getProcedureDefinition() {
		return procedureDefinition;
	}

	public StoredProcedure getStoredProcedure() {
		return storedProcedure;
	}	
}
